package top.wshape1.rpc.loadbalance;

import top.wshape1.rpc.common.entity.ServiceMeta;

import java.util.List;
import java.util.concurrent.ThreadLocalRandom;

/**
 * @author Wshape1
 * @version 1.0
 * @description RandomLoadBalance 随机
 * @since 2024-02-10
 */

public class RandomLoadBalance extends AbstractLoadBalance {


    @Override
    protected ServiceMeta doSelect(List<ServiceMeta> serviceMetas) {
        int size = serviceMetas.size();
        return serviceMetas.get(ThreadLocalRandom.current().nextInt(size));
    }
}
